﻿Imports System.Data.SqlClient

Public Class clsPeriodoInfonavit
    Private mintIdInfonavit As Integer
    Private mintBimestre As Integer
    Private mintDel As Integer
    Private mintAl As Integer
    Private mintAnio As Integer
    Private mstrStatus As String
    Public Property IdInfonavit() As Integer
        Get
            Return mintIdInfonavit
        End Get
        Set(ByVal value As Integer)
            mintIdInfonavit = value
        End Set
    End Property
    Public Property Bimestre() As Integer
        Get
            Return mintBimestre
        End Get
        Set(ByVal value As Integer)
            mintBimestre = value
        End Set
    End Property
    Public Property Del() As Integer
        Get
            Return mintDel
        End Get
        Set(ByVal value As Integer)
            mintDel = value
        End Set
    End Property
    Public Property Al() As Integer
        Get
            Return mintAl
        End Get
        Set(ByVal value As Integer)
            mintAl = value
        End Set
    End Property
    Public Property Anio() As Integer
        Get
            Return mintAnio
        End Get
        Set(ByVal value As Integer)
            mintAnio = value
        End Set
    End Property
    Public Property Status() As String
        Get
            Return mstrStatus
        End Get
        Set(ByVal value As String)
            mstrStatus = value
        End Set
    End Property
    
    Public Sub New()
        mintIdInfonavit = 0
        mintBimestre = 0
        mintDel = 0
        mintAl = 0
        mintAnio = 0
        mstrStatus = ""
    End Sub
    Public Sub Borrar()
        Call SetSqlCitra("Delete From PeriodoInfonavit Where IdInfonavit = " & IdInfonavit)
    End Sub
    Public Sub Insertar()
        Dim sql As String = "Insert Into PeriodoInfonavit (" & _
                            "IdInfonavit," & _
                            "Bimestre," & _
                            "Del," & _
                            "Al," & _
                            "Anio," & _
                            "Status)" & _
                            "VALUES (" & _
                            "@IdInfonavit," & _
                            "@Bimestre," & _
                            "@Del," & _
                            "@Al," & _
                            "@Anio," & _
                            "@Status)"


        Dim cnConn As New SqlConnection
        cnConn.ConnectionString = CitraConnection

        Dim Command As New SqlCommand(sql, cnConn)

        Command.Parameters.AddWithValue("IdInfonavit", mintIdInfonavit)
        Command.Parameters.AddWithValue("Bimestre", mintBimestre)
        Command.Parameters.AddWithValue("Del", mintDel)
        Command.Parameters.AddWithValue("Al", mintAl)
        Command.Parameters.AddWithValue("Anio", mintAnio)
        Command.Parameters.AddWithValue("Status", mstrStatus)

        cnConn.Open()
        Dim RowsAffected As Integer = Command.ExecuteNonQuery

        If RowsAffected > 0 Then
            cnConn.Close()
        Else
            MsgBox("No fue posible insertar el bimestre " & mintBimestre, MsgBoxStyle.Exclamation, "Aviso")
            If cnConn.State = ConnectionState.Open Then
                cnConn.Close()
            End If
        End If
    End Sub
End Class
